const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/db');

const ApiLog = sequelize.define('ApiLog', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
  },
  path: {
    type: DataTypes.STRING,
    allowNull: false,
  },
  method: {
    type: DataTypes.STRING,
    allowNull: false,
  },
  status: {
    type: DataTypes.INTEGER,
  },
  ip: {
    type: DataTypes.STRING,
  },
  response_time: {
    type: DataTypes.INTEGER,
    comment: 'Response time in milliseconds',
  },
  description: {
    type: DataTypes.STRING,
  },
}, {
  tableName: 'api_logs',
  timestamps: true,
});

module.exports = ApiLog;